package com.smart.community.commons.entity.property;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 用户物业公司关联实体类
 * 
 * 注意：此表不使用软删除，直接使用物理删除
 * 原因：用户物业公司关联表是中间表，不需要软删除功能
 * 设计原则：根据"智慧社区微服务架构总览.md"中的关联表设计原则
 * 
 * @author Wu.Liang
 * @version 1.0.0
 * @since 2025-06-29
 */
@Data
@TableName("sc_user_property_company")
@Schema(description = "用户物业公司关联信息")
public class UserPropertyCompany implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    /**
     * 状态枚举
     */
    public static class Status {
        /** 离职 */
        public static final Integer RESIGNED = 0;
        /** 在职 */
        public static final Integer EMPLOYED = 1;
        /** 待入职 */
        public static final Integer PENDING = 2;
    }
    
    @TableId(value = "id", type = IdType.AUTO)
    @Schema(description = "关联ID")
    private Long id;
    
    @NotNull(message = "用户ID不能为空")
    @Min(value = 1, message = "用户ID必须大于0")
    @TableField("user_id")
    @Schema(description = "用户ID", required = true)
    private Long userId;
    
    @NotNull(message = "物业公司ID不能为空")
    @Min(value = 1, message = "物业公司ID必须大于0")
    @TableField("property_company_id")
    @Schema(description = "物业公司ID", required = true)
    private Long propertyCompanyId;
    
    @Size(max = 50, message = "职位长度不能超过50个字符")
    @TableField("position")
    @Schema(description = "职位")
    private String position;
    
    @Size(max = 50, message = "部门长度不能超过50个字符")
    @TableField("department")
    @Schema(description = "部门")
    private String department;
    
    @Size(max = 50, message = "员工编号长度不能超过50个字符")
    @TableField("employee_no")
    @Schema(description = "员工编号")
    private String employeeNo;
    
    @JsonFormat(pattern = "yyyy-MM-dd")
    @TableField("join_date")
    @Schema(description = "入职日期")
    private LocalDate joinDate;
    
    @Min(value = 0, message = "状态值不正确")
    @Max(value = 2, message = "状态值不正确")
    @TableField("status")
    @Schema(description = "状态：0-离职，1-在职，2-待入职")
    private Integer status;
    
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "创建时间")
    private LocalDateTime createTime;
    
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "更新时间")
    private LocalDateTime updateTime;
    
    @TableField(fill = FieldFill.INSERT)
    @Schema(description = "创建人")
    private Long createBy;
    
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新人")
    private Long updateBy;
    
    @Version
    @TableField("version")
    @Schema(description = "乐观锁版本号")
    private Integer version;
    
    @TableField("remark")
    @Schema(description = "备注")
    private String remark;
}
